btez2 2.2.0
Loading...
Searching...
No Matches
btez2


BT-EZ 2 Click

BT-EZ 2 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Feb 2025.
  • Type : UART type

Software Support

Example Description

This example demonstrates the use of BT-EZ 2 Click board by processing data from a connected BLE device.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.BTEZ2

Example Key Functions

  • btez2_cfg_setup This function initializes Click configuration structure to initial values.
    void btez2_cfg_setup(btez2_cfg_t *cfg)
    BT-EZ 2 configuration object setup function.
    BT-EZ 2 Click configuration object.
    Definition btez2.h:281
  • btez2_init This function initializes all necessary pins and peripherals used for this Click board.
    err_t btez2_init ( btez2_t *ctx, btez2_cfg_t *cfg );
    err_t btez2_init(btez2_t *ctx, btez2_cfg_t *cfg)
    BT-EZ 2 initialization function.
    BT-EZ 2 Click context object.
    Definition btez2.h:256
  • btez2_cmd_action This function sends a specified action command to the Click module.
    void btez2_cmd_action ( btez2_t *ctx, uint8_t *cmd, uint8_t *params );
    void btez2_cmd_action(btez2_t *ctx, uint8_t *cmd, uint8_t *params)
    BT-EZ 2 cmd action function.
  • btez2_cmd_set This function sends a specified set command to the Click module.
    void btez2_cmd_set ( btez2_t *ctx, uint8_t *cmd, uint8_t *params );
    void btez2_cmd_set(btez2_t *ctx, uint8_t *cmd, uint8_t *params)
    BT-EZ 2 cmd set function.
  • btez2_read_packet This function reads a response or event packet from the Click module and stores it in ctx->evt_pkt structure.
    err_t btez2_read_packet ( btez2_t *ctx );
    err_t btez2_read_packet(btez2_t *ctx)
    BT-EZ 2 read packet function.

Application Init

Initializes the driver and logger.

void application_init ( void )
{
log_cfg_t log_cfg;
btez2_cfg_t btez2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
btez2_cfg_setup( &btez2_cfg );
BTEZ2_MAP_MIKROBUS( btez2_cfg, MIKROBUS_1 );
if ( UART_ERROR == btez2_init( &btez2, &btez2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
app_state = BTEZ2_POWER_UP;
log_printf( &logger, ">>> APP STATE - POWER UP <<<\r\n\n" );
}
#define BTEZ2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition btez2.h:226
void application_init(void)
Definition main.c:150
@ BTEZ2_POWER_UP
Definition main.c:63

Application Task

Application task is split in few stages:

  • BTEZ2_POWER_UP:

    Powers up the device and checks the communication.

  • BTEZ2_CONFIG_EXAMPLE:

    Restores factory settings and reads the BT address and name.

  • BTEZ2_EXAMPLE:

    Performs a BT terminal example by processing all data from a connected BLE device and sending back an adequate response messages.

void application_task ( void )
{
switch ( app_state )
{
{
if ( BTEZ2_OK == btez2_power_up( &btez2 ) )
{
app_state = BTEZ2_CONFIG_EXAMPLE;
log_printf( &logger, ">>> APP STATE - CONFIG EXAMPLE <<<\r\n\n" );
}
break;
}
{
if ( BTEZ2_OK == btez2_config_example( &btez2 ) )
{
app_state = BTEZ2_EXAMPLE;
log_printf( &logger, ">>> APP STATE - EXAMPLE <<<\r\n\n" );
}
break;
}
{
btez2_example( &btez2 );
break;
}
default:
{
log_error( &logger, " APP STATE." );
break;
}
}
}
@ BTEZ2_OK
Definition btez2.h:307
void application_task(void)
Definition main.c:183
@ BTEZ2_EXAMPLE
Definition main.c:65
@ BTEZ2_CONFIG_EXAMPLE
Definition main.c:64

Note

We have used the Serial Bluetooth Terminal smartphone application for the test.

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.